﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.Text;
using System.Threading.Tasks;

namespace Sern.Abstracts.Common
{
    [ServiceContract]
    public interface IMapReduceHost
    {
        /// <summary>
        /// Allow package to be chunkified and stored locally.
        /// </summary>
        /// <param name="packageId"> </param>
        /// <param name="installerPackage"> </param>
        /// <remarks>
        /// </remarks>
        /// <returns>The uri of the newly installed service.
        /// </returns>
        [OperationContract]
        void UploadClient(Guid packageId, byte[] installerPackage);


        /// <summary>
        /// Start a new appdomain of the installer package whose id is PackageId and instruct it to register itself against the given tracker uri.
        /// </summary>
        /// <param name="packageId"> </param>
        /// <param name="trackerId"> </param>
        /// <param name="trackerUri"></param>
        /// <returns>The id of the newly created package instance to the trackerUri</returns>
        [OperationContract]
        void Register(Guid packageId, Guid trackerId, string trackerUri);

        /// <summary>
        /// Remove the given service uri from the tracker uri. You must obtain the packageInstanceId from the earlier call to register.
        /// </summary>
        /// <param name="packageInstanceId"> </param>
        [OperationContract]
        void Deregister(Guid packageInstanceId);

        #region For now the remote controller service can only end itself via root access. It's controlled services however may be terminated remotely.
        ///// <summary>
        ///// Remove the service at the given uri.
        ///// </summary>
        ///// <param name="uri"></param>
        //void Remove(string uri);
        #endregion
    }
}
